<template>
	<view>
		<!-- 导航栏 -->
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">测试测试</block>
		</cu-custom>
		<view class="bg-white">
			<view class="article-meta">
				<text class="article-author">Admin</text>
				<text class="article-text">发表于</text>
				<text class="article-time">2020-03-12 23:45:58</text>
			</view>
			<view class="article-content">
				<rich-text :nodes="htmlNodes"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	import htmlParser from '@/common/html-parser.js'
	
	export default {
		data() {
			return {
				info:[],
				htmlNodes: [],
				
			}
		},
		onLoad(event) {
			if(event == 'xszd'){
				console.log(123);
				return
			}
			// TODO 后面把参数名替换成 payload
			const payload = event.detailDate || event.payload;
			// 目前在某些平台参数会被主动 decode，暂时这样处理。
			try {
				this.banner = JSON.parse(decodeURIComponent(payload));
			} catch (error) {
				this.banner = JSON.parse(payload);
			}
			
			var htmlString = this.banner.content.replace(/\\/g, "").replace(/<img/g, "<img style=\"display:none;\"");
			this.htmlNodes = htmlParser(htmlString);
			
			this.info = this.banner;
		},
		methods: {
		}
	}
</script>

<style>
	@import '../../common/uni.css';
	.article-meta {
		padding: 20upx 40upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		color: black;
	}

	.article-text {
		font-size: 26upx;
		line-height: 50upx;
		margin: 0 20upx;
	}

	.article-author,
	.article-time {
		font-size: 30upx;
	}

	.article-content {
		padding: 0 30upx;
		overflow: hidden;
		font-size: 30upx;
		margin-bottom: 30upx;
	}
	
	.article-content {
		// 该属性存在兼容性问题，详情参考下方文档
		user-select: text;
	}
</style>
